package com.mrjy.maintain.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.mrjy.common.entity.TeacherInfo;
import com.mrjy.common.entity.VideoInfo;
import com.mrjy.maintain.bo.ITeacherInfoBo;
import com.mrjy.maintain.dto.TeacherInfoDTO;
import com.mrjy.maintain.dto.TeacherParamDTO;
import com.mrjy.maintain.dto.TeachersRecordAuthParamDTO;

@RequestMapping("/maintain/teacherInfo")
@Controller
public class TeacherInfoController {

	@Resource
	private ITeacherInfoBo teacherInfoBo;
	
	@RequestMapping("/add")
	@ResponseBody
	public Object insert(TeacherInfoDTO info,HttpSession session) {
		return teacherInfoBo.txInsert(info,session);
	}

	@RequestMapping("/deleteByIds")
	@ResponseBody
	public Object deleteByIds(int[] ids) {		
		return teacherInfoBo.txDeleteByIds(ids);
	}
	
		
	@RequestMapping("/edit")
	@ResponseBody
	public Object updateById(TeacherInfoDTO info,HttpSession session) {
		return teacherInfoBo.txUpdateById(info,session);
	}
	
	@RequestMapping("/queryById")
	@ResponseBody
	public Object queryById(int id) {
		return teacherInfoBo.queryById(id);
	}
	/**
	 * 
	 * @param id
	 * @return
	 */
	@RequestMapping("/queryPage")
	@ResponseBody
	public Object queryPage(TeacherInfoDTO dto,HttpSession session) {
		return teacherInfoBo.queryPage(dto,session);
	}
	
	/**
	 * 禁用、起用
	 * @param ids
	 * @return
	 */
	@RequestMapping("/updateDisableFlag")
	@ResponseBody
	public Object updateDisableFlag(TeacherInfo info,HttpSession session) {		
		return teacherInfoBo.txUpdateDisableFlag(info,session);
    }

    @RequestMapping("/queryByUserId")
    @ResponseBody
    public Object queryByUserId(TeacherInfo info) {
        return teacherInfoBo.queryByUserId(info);
    }
    

    @RequestMapping("/txUpdateByUserId")
    @ResponseBody
    public Object txUpdateByUserId(TeacherInfo info) {
        return teacherInfoBo.txUpdateByUserId(info);
    }
    
    
    @RequestMapping("/export")
    @ResponseBody
    public Object export(TeacherInfoDTO dto,HttpServletResponse response,HttpSession session){
		return teacherInfoBo.exportExl(dto,response,session);
    }

    /**
     * 根据user_id删除teacher
     *
     * @param ids
     * @return
     */
    @RequestMapping("/deleteTeacherByIds")
    @ResponseBody
    public Object deleteTeacherByIds(int[] ids) {
        return teacherInfoBo.txDeleteTeacherByIds(ids);
    }


    /**
     * 根据video_type_ids查询视频资源
     *
     * @param ids
     * @param session
     * @return
     */
    @RequestMapping("/queryTeacherWithCourse")
    @ResponseBody
    public Object queryTeacherWithCourse(VideoInfo info, HttpSession session) {
        return teacherInfoBo.queryTeacherWithCourse(info, session);
    }
    /**
     * 1.6.9.3 查询有回答权限的老师，可根据typeIds查询相关标签的讲师
     * @param rows
     * @param page
     * @param typeIds 用,拼接的标签Id
     * @return
     */
    @RequestMapping("/hasRecordAuth/list")
    @ResponseBody
    public Object queryTeachersHasRecordAuth(TeachersRecordAuthParamDTO dto, HttpSession session) {
    	/*UserInfo loginUser = (UserInfo) session.getAttribute(GlobalConstant.USER_INFO);
		if(null == loginUser ){
			throw new InnerException(ResultEnum.NOT_LOGIN);
		}*/
        return teacherInfoBo.queryTeachersHasRecordAuth(dto);
    }
    /**
     * 微信端获取明师列表
     * @param dto
     * @param session
     * @return
     */
    @RequestMapping(value = "/teachers" , method = RequestMethod.GET)
    @ResponseBody
    public Object queryTeacherList(TeacherParamDTO dto, HttpSession session) {
    	/*UserInfo loginUser = (UserInfo) session.getAttribute(GlobalConstant.USER_INFO);
		if(null == loginUser ){
			throw new InnerException(ResultEnum.NOT_LOGIN);
		}*/
        return teacherInfoBo.queryTeacherList(dto);
    }

}
